package com.pro.admin.web.guanwang;


import com.pro.admin.annotation.RequiresPermissionsDesc;
import com.pro.admin.web.BaseController;
import com.pro.core.util.ResponseUtil;
import com.pro.db.service.itf.IGuopuSettingService;
import com.pro.db.vo.StatVo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * <p>
 * 首页 前端控制器
 * </p>
 *
 * @author wanglei
 * @since 2019-12-22
 */
@RestController
@RequestMapping("/admin/stat")
public class GuopuStatController extends BaseController {
    private final Log logger = LogFactory.getLog(GuopuStatController.class);

    /**
     * @apiDefine stat 首页数据
     *
     */


    /**
     * @api {Get} /admin/stat/dashboard 0.1 获取实时统计数据
     * @apiName stat dashboard
     * @apiGroup stat
     * @apiVersion 1.0.0
     * @apiDescription 接口负责人-王雷
     *
     * @apiSuccess {int} errno 结果码 0:正常返回,-1服务异常
     * @apiSuccess {String} errmsg 前端提示消息
     * @apiSuccess {Object} data 结果集
     * @apiSuccessExample Success-Response:
     * HTTP/1.1 200 OK
    {
     *     "errno": 0,
     *     "errmsg": "成功"
     * }
     */
    @RequiresPermissions("admin:stat:dashboard")
    @RequiresPermissionsDesc(menu={"实时统计管理" , "实时统计信息"}, button="获取实时统计数据")
    @GetMapping("/dashboard")
    public Object dashboard() {
        HashMap<String,String> map = new HashMap<>();
        map.put("userTotal","123");
        map.put("topicTotal","423");
        map.put("commentTotal","98452");
        map.put("likeTotal","8452");
        return ResponseUtil.ok(map);
    }

    /**
     * @api {Get} /admin/stat/user 0.2 获取用户统计
     * @apiName stat user
     * @apiGroup stat
     * @apiVersion 1.0.0
     * @apiDescription 接口负责人-王雷
     *
     * @apiSuccess {int} errno 结果码 0:正常返回,-1服务异常
     * @apiSuccess {String} errmsg 前端提示消息
     * @apiSuccess {Object} data 结果集
     * @apiSuccessExample Success-Response:
     * HTTP/1.1 200 OK
    {
     *     "errno": 0,
     *     "errmsg": "成功"
     * }
     */
    @RequiresPermissions("admin:stat:user")
    @RequiresPermissionsDesc(menu={"实时统计管理" , "实时统计信息"}, button="获取实时用户统计")
    @GetMapping("/user")
    public Object user() {
        StatVo userStatVo = new StatVo();
        List<String> cs = new ArrayList<>();
        cs.add("day");
        cs.add("users");
        userStatVo.setColumns(cs);
        List<StatVo.UserDay> list = new ArrayList<>();
        StatVo.UserDay userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-20");
        userDay.setUsers("10");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-21");
        userDay.setUsers("22");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-22");
        userDay.setUsers("23");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-23");
        userDay.setUsers("12");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-24");
        userDay.setUsers("42");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-25");
        userDay.setUsers("26");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-26");
        userDay.setUsers("13");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-27");
        userDay.setUsers("24");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-28");
        userDay.setUsers("11");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-29");
        userDay.setUsers("32");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-30");
        userDay.setUsers("15");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-31");
        userDay.setUsers("22");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-01");
        userDay.setUsers("34");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-02");
        userDay.setUsers("31");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-03");
        userDay.setUsers("13");
        list.add(userDay);
        userStatVo.setRows(list);
        return ResponseUtil.ok(userStatVo);
    }

    /**
     * @api {Get} /admin/stat/topic 0.3 获取帖子统计
     * @apiName stat topic
     * @apiGroup stat
     * @apiVersion 1.0.0
     * @apiDescription 接口负责人-王雷
     *
     * @apiSuccess {int} errno 结果码 0:正常返回,-1服务异常
     * @apiSuccess {String} errmsg 前端提示消息
     * @apiSuccess {Object} data 结果集
     * @apiSuccessExample Success-Response:
     * HTTP/1.1 200 OK
    {
     *     "errno": 0,
     *     "errmsg": "成功"
     * }
     */
    @RequiresPermissions("admin:stat:topic")
    @RequiresPermissionsDesc(menu={"实时统计管理" , "实时统计信息"}, button="获取实时帖子统计")
    @GetMapping("/topic")
    public Object topic() {
        StatVo topicVo = new StatVo();
        List<String> cs = new ArrayList<>();
        cs.add("day");
        cs.add("topics");
        topicVo.setColumns(cs);
        List<StatVo.UserDay> list = new ArrayList<>();
        StatVo.UserDay userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-20");
        userDay.setTopics("10");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-21");
        userDay.setTopics("27");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-22");
        userDay.setTopics("25");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-23");
        userDay.setTopics("24");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-24");
        userDay.setTopics("21");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-25");
        userDay.setTopics("22");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-26");
        userDay.setTopics("23");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-27");
        userDay.setTopics("33");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-28");
        userDay.setTopics("23");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-29");
        userDay.setTopics("13");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-30");
        userDay.setTopics("23");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2019-12-31");
        userDay.setTopics("23");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-01");
        userDay.setTopics("34");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-02");
        userDay.setTopics("31");
        list.add(userDay);
        userDay = new StatVo().new UserDay();
        userDay.setDay("2020-01-03");
        userDay.setTopics("16");
        list.add(userDay);
        topicVo.setRows(list);
        return ResponseUtil.ok(topicVo);
    }

}

